package com.itheima.app.controller;

import com.itheima.app.mapper.MessageManager;
import com.itheima.vo.PageBeanVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MessageController {

    @Autowired
    private MessageManager messageManager;

    //点赞列表
    @GetMapping("/messages/likes")
    public PageBeanVo likes(@RequestParam(value = "page", defaultValue = "1") Integer pageNum,
                            @RequestParam(value = "pagesize", defaultValue = "10") Integer pageSize) {
        Integer commentType = 1;
        PageBeanVo userComment = messageManager.findUserComment(commentType, pageNum, pageSize);
        return userComment;
    }

    //评论列表
    @GetMapping("/messages/comments")
    public PageBeanVo comments(@RequestParam(value = "page", defaultValue = "1") Integer pageNum,
                               @RequestParam(value = "pagesize", defaultValue = "10") Integer pageSize) {
        Integer commentType = 2;
        return messageManager.findUserComment(commentType, pageNum, pageSize);
    }

    //喜欢列表
    @GetMapping("/messages/loves")
    public PageBeanVo loves(@RequestParam(value = "page", defaultValue = "1") Integer pageNum,
                            @RequestParam(value = "pagesize", defaultValue = "10") Integer pageSize) {
        Integer commentType = 3;
        return messageManager.findUserComment(commentType, pageNum, pageSize);
    }

    //公告列表
    @GetMapping("/messages/announcements")
    public PageBeanVo announcements(@RequestParam(value = "page", defaultValue = "1") Integer pageNum,
                            @RequestParam(value = "pagesize", defaultValue = "10") Integer pageSize) {

       return messageManager.findAnnouncements(pageNum, pageSize);
    }
}